package com.ruoyi.web.controller.stock;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.stock.service.WarehouseInStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: YwaiX
 * @Version: 1.0
 * @Date: Created in 2024-10-30 16:34:13
 * @Description:
 */

@RestController
@RequestMapping("/stock/InStock")
public class WarehouseInStockController extends BaseController {

    @Autowired
    private WarehouseInStockService warehouseInStockService;

    /**
     * 查询入库详情的详细信息
     * @param warehouseInInfoId
     * @return
     */
    @PreAuthorize("@ss.hasAnyPermi('stock:in:inStock')")
    @GetMapping("list")
    public AjaxResult list(Integer warehouseInInfoId,Integer goodsType){
        return success(warehouseInStockService.list(warehouseInInfoId,goodsType));
    }

    /**
     * 修改入库id
     * @param warehouseInInfoId
     * @param warehouseId
     * @return
     */
    @PreAuthorize("@ss.hasPermi('stock:in:updateWarehouseId')")
    @PostMapping("/updateWarehouseId")
    public AjaxResult updateWarehouseId(Integer warehouseInInfoId,Integer warehouseId,String goodsNo,Integer number){
        Long userId = getLoginUser().getUserId();
        return toAjax(warehouseInStockService.updateWarehouseId(warehouseInInfoId,warehouseId,goodsNo,number,userId));
    }

    /**
     * 修改入库状态
     * @param warehouseInId
     * @return
     */
    @PreAuthorize("@ss.hasPermi('stock:in:updateWarehouseStatus')")
    @GetMapping("/updateWarehouseStatus")
    public AjaxResult updateWarehouseStatus(Integer warehouseInId){
        return toAjax(warehouseInStockService.updateWarehouseStatus(warehouseInId,getLoginUser().getUserId(), DateUtils.getNowDate()));
    }
}
